package com.reggie.module.entity.dto.categoryDto;

import com.reggie.module.entity.po.Category;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

import static com.reggie.common.Constant.LOGIN_SESSION;

/**
 * @Author 早睡蛋
 * @Date 2022/9/21 19:29:28
 * @Desc:
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpdateCategoryDto {

    private Long id;

    @NotEmpty(message = "分类名称不能为空")
    //分类名称
    private String name;

    //顺序
    private Integer sort;

    private LocalDateTime updateTime;

    private Long updateUser;


    public UpdateCategoryDto(Long id, String name, Integer sort, HttpServletRequest request) {
        this.id = id;
        this.name = name;
        this.sort = sort;
        this.updateTime = LocalDateTime.now();
        Long empId = (Long) request.getSession().getAttribute(LOGIN_SESSION);
        this.updateUser = empId;
    }
}
